<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>最接近的三数之和 | Freeisms</title>
    <meta name="generator" content="VuePress 1.7.1">
    <link rel="icon" href="/favicon.ico">
    <link rel="manifest" href="/manifest.json">
    <link rel="apple-touch-icon" href="/apple-touch-icon.png">
    <meta name="description" content="记录个人前端技术成长点滴">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    
    <link rel="preload" href="/assets/css/0.styles.9efbc543.css" as="style"><link rel="preload" href="/assets/js/app.e45e7f79.js" as="script"><link rel="preload" href="/assets/js/4.1dc261f9.js" as="script"><link rel="preload" href="/assets/js/34.8a018286.js" as="script"><link rel="prefetch" href="/assets/js/10.910e44c4.js"><link rel="prefetch" href="/assets/js/11.3cb7fbc0.js"><link rel="prefetch" href="/assets/js/12.e84e4441.js"><link rel="prefetch" href="/assets/js/13.a20b1e0e.js"><link rel="prefetch" href="/assets/js/14.5bb81eb0.js"><link rel="prefetch" href="/assets/js/15.9ac9c7b5.js"><link rel="prefetch" href="/assets/js/16.e65d6e8b.js"><link rel="prefetch" href="/assets/js/17.3bcb37e9.js"><link rel="prefetch" href="/assets/js/18.238c27dc.js"><link rel="prefetch" href="/assets/js/19.0bf085fb.js"><link rel="prefetch" href="/assets/js/20.af32ca4b.js"><link rel="prefetch" href="/assets/js/21.d7d0a4bf.js"><link rel="prefetch" href="/assets/js/22.fb0bd41c.js"><link rel="prefetch" href="/assets/js/23.e40c513c.js"><link rel="prefetch" href="/assets/js/24.df877caa.js"><link rel="prefetch" href="/assets/js/25.ff943ee7.js"><link rel="prefetch" href="/assets/js/26.6975fab4.js"><link rel="prefetch" href="/assets/js/27.49355cdd.js"><link rel="prefetch" href="/assets/js/28.08ac8c0a.js"><link rel="prefetch" href="/assets/js/29.864244b6.js"><link rel="prefetch" href="/assets/js/30.9fde9cc1.js"><link rel="prefetch" href="/assets/js/31.04c169d6.js"><link rel="prefetch" href="/assets/js/32.57021f58.js"><link rel="prefetch" href="/assets/js/33.09502731.js"><link rel="prefetch" href="/assets/js/35.097f93be.js"><link rel="prefetch" href="/assets/js/36.37ccdfeb.js"><link rel="prefetch" href="/assets/js/37.11976f3e.js"><link rel="prefetch" href="/assets/js/38.98243aad.js"><link rel="prefetch" href="/assets/js/39.a3c78447.js"><link rel="prefetch" href="/assets/js/40.7be6398d.js"><link rel="prefetch" href="/assets/js/41.33d492ee.js"><link rel="prefetch" href="/assets/js/42.f1c675e6.js"><link rel="prefetch" href="/assets/js/43.bbda546b.js"><link rel="prefetch" href="/assets/js/44.2dc401cd.js"><link rel="prefetch" href="/assets/js/45.33bd1151.js"><link rel="prefetch" href="/assets/js/46.b6b09012.js"><link rel="prefetch" href="/assets/js/47.55feb448.js"><link rel="prefetch" href="/assets/js/48.fc9dc909.js"><link rel="prefetch" href="/assets/js/49.fd6d33c4.js"><link rel="prefetch" href="/assets/js/5.ac586c16.js"><link rel="prefetch" href="/assets/js/50.8e33b7f9.js"><link rel="prefetch" href="/assets/js/51.fd278c0a.js"><link rel="prefetch" href="/assets/js/52.fbd66a3b.js"><link rel="prefetch" href="/assets/js/53.f829ac68.js"><link rel="prefetch" href="/assets/js/54.7c7e5ec8.js"><link rel="prefetch" href="/assets/js/55.42e87201.js"><link rel="prefetch" href="/assets/js/56.2301ffbd.js"><link rel="prefetch" href="/assets/js/57.6d5ed1a9.js"><link rel="prefetch" href="/assets/js/58.8dc29eab.js"><link rel="prefetch" href="/assets/js/59.722945c8.js"><link rel="prefetch" href="/assets/js/6.64876e20.js"><link rel="prefetch" href="/assets/js/60.c43354e4.js"><link rel="prefetch" href="/assets/js/61.b9d1ad1d.js"><link rel="prefetch" href="/assets/js/62.d61bfc10.js"><link rel="prefetch" href="/assets/js/63.d84a88b5.js"><link rel="prefetch" href="/assets/js/64.0f25c14d.js"><link rel="prefetch" href="/assets/js/7.d74ac93a.js"><link rel="prefetch" href="/assets/js/8.6c8e2482.js"><link rel="prefetch" href="/assets/js/9.085dc649.js"><link rel="prefetch" href="/assets/js/vendors~flowchart.4e554982.js"><link rel="prefetch" href="/assets/js/vendors~notification.4b668bb8.js">
    <link rel="stylesheet" href="/assets/css/0.styles.9efbc543.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/" class="home-link router-link-active"><!----> <span class="site-name">Freeisms</span></a> <div class="links"><div class="search-box"><input aria-label="Search" autocomplete="off" spellcheck="false" value=""> <!----></div> <nav class="nav-links can-hide"><div class="nav-item"><a href="/my-docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><a href="/my-docs/design-pattern/" class="nav-link">
  设计模式
</a></div><div class="nav-item"><a href="/my-docs/leetcode/" class="nav-link router-link-active">
  LeetCode
</a></div><div class="nav-item"><a href="/my-docs/library/vue-juejin-comment.html" class="nav-link">
  开源库
</a></div><div class="nav-item"><a href="https://www.striveforus.com/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/Fengfengfeng-up/personal-docs" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><a href="/my-docs/js/" class="nav-link">
  JavaScript
</a></div><div class="nav-item"><a href="/my-docs/design-pattern/" class="nav-link">
  设计模式
</a></div><div class="nav-item"><a href="/my-docs/leetcode/" class="nav-link router-link-active">
  LeetCode
</a></div><div class="nav-item"><a href="/my-docs/library/vue-juejin-comment.html" class="nav-link">
  开源库
</a></div><div class="nav-item"><a href="https://www.striveforus.com/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  博客
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></div> <a href="https://github.com/Fengfengfeng-up/personal-docs" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><section class="sidebar-group depth-0"><p class="sidebar-heading open"><span>LeetCode</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/my-docs/leetcode/" aria-current="page" class="sidebar-link">写在前面</a></li><li><a href="/my-docs/leetcode/two-sum.html" class="sidebar-link">两数之和</a></li><li><a href="/my-docs/leetcode/add-two-numbers.html" class="sidebar-link">两数相加</a></li><li><a href="/my-docs/leetcode/longest-substring-without-repeating-characters.html" class="sidebar-link">无重复字符的最长子串</a></li><li><a href="/my-docs/leetcode/median-of-two-sorted-arrays.html" class="sidebar-link">寻找两个正序数组的中位数</a></li><li><a href="/my-docs/leetcode/longest-palindromic-substring.html" class="sidebar-link">最长回文子串</a></li><li><a href="/my-docs/leetcode/zigzag-conversion.html" class="sidebar-link">Z 字形变换</a></li><li><a href="/my-docs/leetcode/reverse-integer.html" class="sidebar-link">整数反转</a></li><li><a href="/my-docs/leetcode/string-to-integer-atoi.html" class="sidebar-link">字符串转换整数 (atoi)</a></li><li><a href="/my-docs/leetcode/palindrome-number.html" class="sidebar-link">回文数</a></li><li><a href="/my-docs/leetcode/regular-expression-matching.html" class="sidebar-link">正则表达式匹配</a></li><li><a href="/my-docs/leetcode/container-with-most-water.html" class="sidebar-link">盛最多水的容器</a></li><li><a href="/my-docs/leetcode/integer-to-roman.html" class="sidebar-link">整数转罗马数字</a></li><li><a href="/my-docs/leetcode/roman-to-integer.html" class="sidebar-link">罗马数字转整数</a></li><li><a href="/my-docs/leetcode/longest-common-prefix.html" class="sidebar-link">最长公共前缀</a></li><li><a href="/my-docs/leetcode/3sum.html" class="sidebar-link">三数之和</a></li><li><a href="/my-docs/leetcode/3sum-closest.html" aria-current="page" class="active sidebar-link">最接近的三数之和</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/my-docs/leetcode/3sum-closest.html#题目" class="sidebar-link">题目</a></li><li class="sidebar-sub-header"><a href="/my-docs/leetcode/3sum-closest.html#解题思路" class="sidebar-link">解题思路</a></li><li class="sidebar-sub-header"><a href="/my-docs/leetcode/3sum-closest.html#代码实现" class="sidebar-link">代码实现</a></li></ul></li><li><a href="/my-docs/leetcode/letter-combinations-of-a-phone-number.html" class="sidebar-link">电话号码的字母组合</a></li><li><a href="/my-docs/leetcode/4sum.html" class="sidebar-link">四数之和</a></li><li><a href="/my-docs/leetcode/remove-nth-node-from-end-of-list.html" class="sidebar-link">删除链表的倒数第 N 个结点</a></li><li><a href="/my-docs/leetcode/valid-parentheses.html" class="sidebar-link">有效的括号</a></li><li><a href="/my-docs/leetcode/merge-two-sorted-lists.html" class="sidebar-link">合并两个有序链表</a></li><li><a href="/my-docs/leetcode/generate-parentheses.html" class="sidebar-link">括号生成</a></li><li><a href="/my-docs/leetcode/merge-k-sorted-lists.html" class="sidebar-link">合并K个升序链表</a></li><li><a href="/my-docs/leetcode/swap-nodes-in-pairs.html" class="sidebar-link">两两交换链表中的节点</a></li><li><a href="/my-docs/leetcode/reverse-nodes-in-k-group.html" class="sidebar-link">K 个一组翻转链表</a></li><li><a href="/my-docs/leetcode/remove-duplicates-from-sorted-array.html" class="sidebar-link">删除排序数组中的重复项</a></li><li><a href="/my-docs/leetcode/remove-element.html" class="sidebar-link">移除元素</a></li><li><a href="/my-docs/leetcode/implement-strstr.html" class="sidebar-link">实现 strStr()</a></li><li><a href="/my-docs/leetcode/divide-two-integers.html" class="sidebar-link">两数相除</a></li><li><a href="/my-docs/leetcode/substring-with-concatenation-of-all-words.html" class="sidebar-link">串联所有单词的子串</a></li><li><a href="/my-docs/leetcode/next-permutation.html" class="sidebar-link">下一个排列</a></li></ul></section></li></ul> </aside> <main class="page"> <div class="theme-default-content content__default"><h1 id="最接近的三数之和"><a href="#最接近的三数之和" class="header-anchor">#</a> 最接近的三数之和</h1> <p>力扣🔗：<a href="https://leetcode-cn.com/problems/3sum-closest" target="_blank" rel="noopener noreferrer">https://leetcode-cn.com/problems/3sum-closest<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></p> <h2 id="题目"><a href="#题目" class="header-anchor">#</a> 题目</h2> <p>给定一个包括 n 个整数的数组 <code>nums</code> 和 一个目标值 <code>target</code>。找出 <code>nums</code> 中的三个整数，使得它们的和与 <code>target</code> 最接近。返回这三个数的和。假定每组输入只存在唯一答案。</p> <p><strong>示例：</strong></p> <div class="language- extra-class"><pre><code>输入：nums = [-1,2,1,-4], target = 1
输出：2
解释：与 target 最接近的和是 2 (-1 + 2 + 1 = 2) 。
</code></pre></div><p><strong>提示：</strong></p> <ul><li><code>3 &lt;= nums.length &lt;= 10^3</code></li> <li><code>-10^3 &lt;= nums[i] &lt;= 10^3</code></li> <li><code>-10^4 &lt;= target &lt;= 10^4</code></li></ul> <h2 id="解题思路"><a href="#解题思路" class="header-anchor">#</a> 解题思路</h2> <ul><li><p>首先将 <code>nums</code> 由小到大进行排序。</p></li> <li><p>然后从左往右依次遍历 <code>nums</code> 中每个值，记录索引值为 <code>base</code>，直到 <code>base</code> 等于 <code>nums.length - 3</code>，也就是倒数第三个整数。若 <code>nums[base] === num[base - 1]</code>，则跳过当前循环。</p></li> <li><p>在每个循环体中，<code>nums[base]</code> 作为固定的加数，设置左指针 <code>left</code> 和右指针 <code>right</code>，初始值分别为 <code>base + 1</code> 和 <code>nums.length - 1</code>。</p></li> <li><p>变量 <code>result</code> 表示结果，变量 <code>sum</code> 表示当前循环中的三数之和 <code>nums[base] + nums[left] + nums[right]</code>。根据以下情况移动双指针：</p> <ul><li>当 <code>sum &lt; target</code> 时，表示左边两数之和较小，因此向右移动左指针。</li> <li>当 <code>sum &gt; target</code> 时，表示左边两数之和较大，因此向左移动右指针。</li> <li>当 <code>sum === target</code> 时，表示已是最接近 <code>target</code> 的数，因此直接返回 <code>sum</code>。</li> <li>如果当前三数之和更接近 <code>target</code> 或 <code>result</code> 未赋值，则更新 <code>result = sum</code>。</li></ul></li></ul> <h2 id="代码实现"><a href="#代码实现" class="header-anchor">#</a> 代码实现</h2> <div class="language-js extra-class"><pre class="language-js"><code><span class="token comment">/**
 * @param {number[]} nums
 * @param {number} target
 * @return {number}
 */</span>
<span class="token keyword">function</span> <span class="token function">threeSumClosest</span><span class="token punctuation">(</span><span class="token parameter">nums<span class="token punctuation">,</span> target</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  nums<span class="token punctuation">.</span><span class="token function">sort</span><span class="token punctuation">(</span><span class="token punctuation">(</span><span class="token parameter">a<span class="token punctuation">,</span> b</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> a <span class="token operator">-</span> b<span class="token punctuation">)</span> <span class="token comment">// 由小到大对数组进行排序</span>
  <span class="token keyword">const</span> l <span class="token operator">=</span> nums<span class="token punctuation">.</span>length
  <span class="token keyword">let</span> result

  <span class="token keyword">for</span> <span class="token punctuation">(</span><span class="token keyword">let</span> base <span class="token operator">=</span> <span class="token number">0</span><span class="token punctuation">;</span> base <span class="token operator">&lt;</span> l <span class="token operator">-</span> <span class="token number">2</span><span class="token punctuation">;</span> base<span class="token operator">++</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    <span class="token keyword">if</span> <span class="token punctuation">(</span>nums<span class="token punctuation">[</span>base<span class="token punctuation">]</span> <span class="token operator">===</span> nums<span class="token punctuation">[</span>base <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token keyword">continue</span>
    <span class="token keyword">let</span> left <span class="token operator">=</span> base <span class="token operator">+</span> <span class="token number">1</span> <span class="token comment">// 左指针</span>
    <span class="token keyword">let</span> right <span class="token operator">=</span> l <span class="token operator">-</span> <span class="token number">1</span> <span class="token comment">// 右指针</span>

    <span class="token keyword">while</span> <span class="token punctuation">(</span>left <span class="token operator">&lt;</span> right<span class="token punctuation">)</span> <span class="token punctuation">{</span>
      <span class="token comment">// 每循环一次，当前的 nums[base] 作为不变的加数，移动双指针寻找符合条件的值</span>
      <span class="token keyword">const</span> sum <span class="token operator">=</span> nums<span class="token punctuation">[</span>base<span class="token punctuation">]</span> <span class="token operator">+</span> nums<span class="token punctuation">[</span>left<span class="token punctuation">]</span> <span class="token operator">+</span> nums<span class="token punctuation">[</span>right<span class="token punctuation">]</span>
      <span class="token keyword">if</span> <span class="token punctuation">(</span>sum <span class="token operator">===</span> target<span class="token punctuation">)</span> <span class="token keyword">return</span> sum

      <span class="token keyword">if</span> <span class="token punctuation">(</span>sum <span class="token operator">&lt;</span> target<span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 当三数之和小于 target 时，向右移动左指针</span>
        <span class="token keyword">while</span> <span class="token punctuation">(</span>left <span class="token operator">&lt;</span> right <span class="token operator">&amp;&amp;</span> nums<span class="token punctuation">[</span>left<span class="token punctuation">]</span> <span class="token operator">===</span> nums<span class="token punctuation">[</span>left <span class="token operator">+</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token comment">// 当左指针指向的值与它右边的值相等时，向右移动左指针</span>
          left<span class="token operator">++</span>
        <span class="token punctuation">}</span>
        left<span class="token operator">++</span>
      <span class="token punctuation">}</span> <span class="token keyword">else</span> <span class="token punctuation">{</span>
        <span class="token comment">// 当三数之和大于 target 时，向右移动左指针</span>
        <span class="token keyword">while</span> <span class="token punctuation">(</span>right <span class="token operator">&gt;</span> left <span class="token operator">&amp;&amp;</span> nums<span class="token punctuation">[</span>right<span class="token punctuation">]</span> <span class="token operator">===</span> nums<span class="token punctuation">[</span>right <span class="token operator">-</span> <span class="token number">1</span><span class="token punctuation">]</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
          <span class="token comment">// 当右指针指向的值与它左边的值相等时，向左移动右指针</span>
          right<span class="token operator">--</span>
        <span class="token punctuation">}</span>
        right<span class="token operator">--</span>
      <span class="token punctuation">}</span>

      <span class="token keyword">if</span> <span class="token punctuation">(</span>Math<span class="token punctuation">.</span><span class="token function">abs</span><span class="token punctuation">(</span>result <span class="token operator">-</span> target<span class="token punctuation">)</span> <span class="token operator">&gt;</span> Math<span class="token punctuation">.</span><span class="token function">abs</span><span class="token punctuation">(</span>sum <span class="token operator">-</span> target<span class="token punctuation">)</span> <span class="token operator">||</span> result <span class="token operator">===</span> <span class="token keyword">undefined</span> <span class="token punctuation">)</span> <span class="token punctuation">{</span>
        <span class="token comment">// 如果当前三数之和更接近 target 或者 result 未赋值，则对 result 进行更新 </span>
        result <span class="token operator">=</span> sum
      <span class="token punctuation">}</span>
    <span class="token punctuation">}</span>
  <span class="token punctuation">}</span>

  <span class="token keyword">return</span> result
<span class="token punctuation">}</span>
</code></pre></div></div> <footer class="page-edit"><div class="edit-link"><a href="https://github.com/Fengfengfeng-up/personal-docs/edit/main/docs/my-docs/leetcode/3sum-closest.md" target="_blank" rel="noopener noreferrer">在 GitHub 上编辑此页</a> <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></div> <div class="last-updated"><span class="prefix">上次更新:</span> <span class="time">1/24/2021, 1:30:53 PM</span></div></footer> <div class="page-nav"><p class="inner"><span class="prev">
      ←
      <a href="/my-docs/leetcode/3sum.html" class="prev">
        三数之和
      </a></span> <span class="next"><a href="/my-docs/leetcode/letter-combinations-of-a-phone-number.html">
        电话号码的字母组合
      </a>
      →
    </span></p></div> </main></div><div class="global-ui"><!----></div></div>
    <script src="/assets/js/app.e45e7f79.js" defer></script><script src="/assets/js/4.1dc261f9.js" defer></script><script src="/assets/js/34.8a018286.js" defer></script>
  </body>
</html>
